package com.ljh.myaiagent.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.ai.chat.messages.MessageType;

import java.io.Serializable;
import java.util.Map;
import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@TableName(value = "`chat_message`", autoResultMap = true)
public class ChatMessage implements Serializable {
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private String id;

    @TableField("conversation_id")
    private String conversationId;

    @TableField("message_type")
    private MessageType messageType; // USER or ASSISTANT

    @TableField("content")
    private String content;

    @TableField(value = "metadata", typeHandler = JacksonTypeHandler.class)
    private Map<String, Object> metadata; // JSON string for extensibility

    @TableField(value = "`create_time`", fill = FieldFill.INSERT)
    private Date createTime;

    @TableField(value = "`update_time`", fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    @TableField("`is_delete`")
    @TableLogic
    private boolean isDelete;
}
